import classes from '../../apis/classes';

export default {
  namespaced: true,
  state: {
    loading: false,
    classes: [],
    count: 0,
  },
  mutations: {
    setLoading(state, data) {
      state.loading = data;
    },
    setClasses(state, data) {
      state.classes = data;
    },
    setCount(state, data) {
      state.count = data;
    },
  },
  actions: {
    async getClasses({ commit }, data) {
      commit('setLoading', true);
      const { data: { result, count } } = await classes.getClasses(data);
      commit('setClasses', result);
      commit('setCount', count);
      commit('setLoading', false);
    },
  },
};
